home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
676-700
/
681
/
term
/
source.lha
/
CopyPanel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-09
|
12KB
|
402 lines
/*
** $Id: CopyPanel.c,v 1.4 92/04/21 16:58:32 olsen Sta Locker: olsen $
** $Revision: 1.4 $
** $Date: 92/04/21 16:58:32 $
**
** Editing panel for configuration copying
**
** Copyright © 1990-1992 by Olaf `Olsen' Barthel & MXM
** All Rights Reserved
*/
#include "termGlobal.h"
enum { GAD_SERIAL,GAD_MODEM,GAD_SCREEN,GAD_TERMINAL,GAD_COMMANDS,
GAD_KEYMACROS,GAD_TRANSFER,GAD_PATHS,GAD_MISC,GAD_FASTMACROS,
GAD_COPYTOALL,GAD_ALL,GAD_CLEAR,GAD_USE,GAD_CANCEL };
#define WIDTH 181
#define HEIGHT 191
STATIC ULONG Bits = 0;
STATIC struct Gadget *
CreateAllGadgets(struct Gadget **GadgetArray,struct Gadget **GadgetList,APTR VisualInfo,UWORD TopEdge)
{
struct Gadget *Gadget;
struct NewGadget NewGadget;
UWORD Counter = 0;
memset(&NewGadget,0,sizeof(struct NewGadget));
if(Gadget = CreateContext(GadgetList))
{
NewGadget . ng_LeftEdge = 10;
NewGadget . ng_TopEdge = 25;
NewGadget . ng_Width = 26;
NewGadget . ng_Height = 11;
NewGadget . ng_GadgetText = LocaleString(MSG_COPYPANEL_SERIAL_GAD);
NewGadget . ng_TextAttr = &DefaultFont;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = PLACETEXT_RIGHT;
NewGadget . ng_VisualInfo = VisualInfo;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Bits & (1 << 0),
TAG_DONE);
NewGadget . ng_TopEdge = 37;
NewGadget . ng_GadgetText = LocaleString(MSG_COPYPANEL_MODEM_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Bits & (1 << 1),
TAG_DONE);
NewGadget . ng_TopEdge = 61;
NewGadget . ng_GadgetText = LocaleString(MSG_COPYPANEL_SCREEN_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Bits & (1 << 2),
TAG_DONE);
NewGadget . ng_TopEdge = 73;
NewGadget . ng_GadgetText = LocaleString(MSG_COPYPANEL_TERMINAL_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Bits & (1 << 3),
TAG_DONE);
NewGadget . ng_TopEdge = 85;
NewGadget . ng_GadgetText = LocaleString(MSG_COPYPANEL_COMMANDS_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Bits & (1 << 4),
TAG_DONE);
NewGadget . ng_TopEdge = 109;
NewGadget . ng_GadgetText = LocaleString(MSG_COPYPANEL_KEYBOARD_MACROS_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Bits & (1 << 5),
TAG_DONE);
NewGadget . ng_TopEdge = 49;
NewGadget . ng_GadgetText = LocaleString(MSG_COPYPANEL_TRANSFER_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Bits & (1 << 6),
TAG_DONE);
NewGadget . ng_TopEdge = 97;
NewGadget . ng_GadgetText = LocaleString(MSG_COPYPANEL_PATHS_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Bits & (1 << 7),
TAG_DONE);
NewGadget . ng_TopEdge = 121;
NewGadget . ng_GadgetText = LocaleString(MSG_COPYPANEL_MISCELLANEOUS_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Bits & (1 << 8),
TAG_DONE);
NewGadget . ng_TopEdge = 133;
NewGadget . ng_GadgetText = LocaleString(MSG_COPYPANEL_FAST_MACROS_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Bits & (1 << 9),
TAG_DONE);
NewGadget . ng_TopEdge = 145;
NewGadget . ng_GadgetText = LocaleString(MSG_COPYPANEL_TO_ALL_ENTRIES_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, FALSE,
TAG_DONE);
NewGadget . ng_TopEdge = 160;
NewGadget . ng_Width = 79;
NewGadget . ng_Height = 12;
NewGadget . ng_GadgetText = LocaleString(MSG_COPYPANEL_ALL_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = PLACETEXT_IN;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_LeftEdge = 92;
NewGadget . ng_GadgetText = LocaleString(MSG_COPYPANEL_CLEAR_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_LeftEdge = 10;
NewGadget . ng_TopEdge = 176;
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_USE_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_LeftEdge = WIDTH - 10 - NewGadget . ng_Width;
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_CANCEL_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_Height = 8;
NewGadget . ng_Width = 19 * 8;
NewGadget . ng_LeftEdge = 14;
NewGadget . ng_TopEdge = 14;
NewGadget . ng_GadgetText = LocaleString(MSG_COPYPANEL_SELECT_DATA_TO_COPY_GAD);
NewGadget . ng_Flags = PLACETEXT_IN|NG_HIGHLABEL;
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(TEXT_KIND,Gadget,&NewGadget,
TAG_DONE);
}
return(Gadget);
}
STATIC VOID __regargs
CopyConfig(struct Configuration *MyConfig,BYTE Part)
{
switch(Part)
{
case GAD_SERIAL: memcpy(&MyConfig -> BaudRate,&Config . BaudRate,offsetof(struct Configuration,ModemInit));
MyConfig -> SerBuffSize = Config . SerBuffSize;
break;
case GAD_MODEM: memcpy(&MyConfig -> ModemInit[0],&Config . ModemInit[0],offsetof(struct Configuration,Protocol) - offsetof(struct Configuration,ModemInit));
strcpy(MyConfig -> NoDialTone,Config . NoDialTone);
MyConfig -> CheckCarrier = Config . CheckCarrier;
MyConfig -> DropDTR = Config . DropDTR;
MyConfig -> PassThrough = Config . PassThrough;
break;
case GAD_SCREEN: memcpy(&MyConfig -> DisplayMode,&Config . DisplayMode,offsetof(struct Configuration,CaptureFilter) - offsetof(struct Configuration,DisplayMode));
break;
case GAD_TERMINAL: memcpy(&MyConfig -> CaptureFilter,&Config . CaptureFilter,offsetof(struct Configuration,CursorApp) - offsetof(struct Configuration,CaptureFilter));
memcpy(&MyConfig -> SwapBSDelete,&Config . SwapBSDelete,offsetof(struct Configuration,UploadMacro) - offsetof(struct Configuration,SwapBSDelete));
strcpy(MyConfig -> KeyMapName,Config . KeyMapName);
strcpy(MyConfig -> AnswerBack,Config . AnswerBack);
MyConfig -> TitleBar = Config . TitleBar;
MyConfig -> StatusLine = Config . StatusLine;
MyConfig -> ReceiveCR = Config . ReceiveCR;
MyConfig -> ReceiveLF = Config . ReceiveLF;
MyConfig -> SystemBeep = Config . SystemBeep;
break;
case GAD_COMMANDS: strcpy(MyConfig -> StartupMacro,Config . StartupMacro);
strcpy(MyConfig -> UploadMacro,Config . UploadMacro);
strcpy(MyConfig -> DownloadMacro,Config . DownloadMacro);
break;
case GAD_KEYMACROS: strcpy(MyConfig -> MacroFile,Config . MacroFile);
break;
case GAD_TRANSFER: strcpy(MyConfig -> Protocol,Config . Protocol);
break;
case GAD_MISC: MyConfig -> Priority = Config . Priority;
MyConfig -> OverridePath = Config . OverridePath;
MyConfig -> BackupConfig = Config . BackupConfig;
MyConfig -> MaxLogBuffSize = Config . MaxLogBuffSize;
MyConfig -> BufferEnabled = Config . BufferEnabled;
MyConfig -> SetArchivedBit = Config . SetArchivedBit;
MyConfig -> OpenFastMacroPanel = Config . OpenFastMacroPanel;
break;
case GAD_PATHS: memcpy(&MyConfig -> DefaultStorage[0],&Config . DefaultStorage[0],offsetof(struct Configuration,SwapBSDelete) - offsetof(struct Configuration,DefaultStorage));
break;
case GAD_FASTMACROS: strcpy(MyConfig -> FastMacroFile,Config . FastMacroFile);
break;
}
}
VOID
CopyPanel(struct Configuration *MyConfig)
{
struct Window *PanelWindow;
struct Gadget *GadgetList;
struct Gadget *GadgetArray[GAD_CANCEL + 2];
if(CreateAllGadgets(&GadgetArray[0],&GadgetList,VisualInfo,Screen -> WBorTop + Screen -> Font -> ta_YSize + 1))
{
if(PanelWindow = OpenWindowTags(NULL,
WA_Left, (Screen -> Width - WIDTH) >> 1,
WA_Top, (Screen -> Height - HEIGHT) >> 1,
WA_Width, WIDTH,
WA_Height, HEIGHT,
WA_Activate, TRUE,
WA_DragBar, TRUE,
WA_DepthGadget, TRUE,
WA_RMBTrap, TRUE,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_CustomScreen,Screen,
WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY | BUTTONIDCMP | CHECKBOXIDCMP,
WA_Title, LocaleString(MSG_COPYPANEL_COPY_CONFIG_TXT),
TAG_DONE))
{
struct IntuiMessage *Massage;
ULONG Class,Code;
struct Gadget *Gadget;
BYTE Terminated = FALSE;
LONG i;
PushWindow(PanelWindow);
AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
GT_RefreshWindow(PanelWindow,NULL);
if(!MyConfig)
{
GT_SetGadgetAttrs(GadgetArray[GAD_COPYTOALL],PanelWindow,NULL,
GTCB_Checked, TRUE,
GA_Disabled, TRUE,
TAG_DONE);
}
while(!Terminated)
{
WaitPort(PanelWindow -> UserPort);
while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
{
Class = Massage -> Class;
Code = Massage -> Code;
Gadget = (struct Gadget *)Massage -> IAddress;
GT_ReplyIMsg(Massage);
if(Class == IDCMP_VANILLAKEY)
KeySelect(GadgetArray,GAD_CANCEL,Code,PanelWindow,&Gadget,&Class,&Code);
if(Class == IDCMP_CLOSEWINDOW)
Terminated = TRUE;
if(Class == IDCMP_GADGETUP)
{
switch(Gadget -> GadgetID)
{
case GAD_ALL: for(i = GAD_SERIAL ; i <= GAD_FASTMACROS ; i++)
{
GT_SetGadgetAttrs(GadgetArray[i],PanelWindow,NULL,
GTCB_Checked, TRUE,
TAG_DONE);
}
break;
case GAD_CLEAR: for(i = GAD_SERIAL ; i <= GAD_FASTMACROS ; i++)
{
GT_SetGadgetAttrs(GadgetArray[i],PanelWindow,NULL,
GTCB_Checked, FALSE,
TAG_DONE);
}
break;
case GAD_USE: Bits = NULL;
if(GT_CHECKED(GadgetArray[GAD_COPYTOALL]))
{
LONG j;
for(i = GAD_SERIAL ; i <= GAD_FASTMACROS ; i++)
{
if(GT_CHECKED(GadgetArray[i]))
{
for(j = 0 ; j < NumPhoneEntries ; j++)
CopyConfig(&Phonebook[j] -> Config,i);
Bits |= (1 << i);
}
}
}
else
{
if(MyConfig)
{
for(i = GAD_SERIAL ; i <= GAD_FASTMACROS ; i++)
{
if(GT_CHECKED(GadgetArray[i]))
{
CopyConfig(MyConfig,i);
Bits |= (1 << i);
}
}
}
}
Terminated = TRUE;
break;
case GAD_CANCEL:Terminated = TRUE;
break;
default: break;
}
}
}
}
RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
PopWindow();
CloseWindow(PanelWindow);
}
FreeGadgets(GadgetList);
}
}